﻿using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    [Filter("缩放",FilterType.Algorithm)]
    public class AlgorithmResize: FilterBase
    {

        /// <summary>
        /// 输出图像大小
        /// </summary>
        [InputParameter("输出图像大小")]
        public CVSize OutPutSize { get; set; } = new CVSize();
        /// <summary>
        /// 水平缩放
        /// </summary>
        [InputParameter("水平缩放")]
        public int HScale { get; set; }
        /// <summary>
        /// 垂直缩放
        /// </summary>
        [InputParameter("垂直缩放")]
        public int VScale { get; set; }
        /// <summary>
        /// 取样方式
        /// </summary>
        [InputParameter("取样方式")]
        public InterpolationFlags InterpolationFlags { get; set; } = InterpolationFlags.Linear;
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Mat ResizeResult = new Mat();
            Cv2.Resize(mat,ResizeResult,OutPutSize,HScale,VScale, InterpolationFlags);
            return ResultData<Mat>.Accept(TextResource.resize_complete, ResizeResult);
        }
    }
}
